package com.example.newland.myapplication3;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class Main2Activity extends AppCompatActivity {

    private String TAG="Main2Activity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        registerReceiver(receiver,new IntentFilter("broadsend.action"));

    }

    final BroadcastReceiver receiver = new BroadcastReceiver() {//接受数据，
        @Override
        public void onReceive(Context context, Intent intent) {

            Log.d(TAG, "onReceive: aa="+intent.getIntExtra("aa",0));
            Log.d(TAG, "onReceive: bb="+intent.getIntExtra("bb",0));
            Log.d(TAG, "onReceive: cc="+intent.getIntExtra("cc",0));

        }
    };

    public void onClick2(View view) {
        unregisterReceiver(receiver);
        finish();
    }
}
